Skip to content

Integrate [DurableExecution] with the Annotations source generator#2410

Merged
GarrettBeatty merged 3 commits into
devfrom
gcbeatty/durable-annotations
Jun 25, 2026
Merged

Integrate [DurableExecution] with the Annotations source generator#2410
GarrettBeatty merged 3 commits into
devfrom
gcbeatty/durable-annotations

Conversation

@GarrettBeatty

@GarrettBeatty GarrettBeatty commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Add a [DurableExecution] attribute (in Amazon.Lambda.Annotations) and source generator support so a method annotated with [LambdaFunction] + [DurableExecution] generates:

  • a typed-envelope handler wrapper delegating to DurableFunction.WrapAsync<TInput[,TOutput]>
  • a DurableConfig block on the function resource in the generated CFN/SAM template
  • lambda:CheckpointDurableExecution / lambda:GetDurableExecutionState IAM permissions (per-function inline policy; skipped when an explicit Role is set)

Issue #, if available:
#2418
Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Base automatically changed from feature/durablefunction to dev June 11, 2026 17:56
@GarrettBeatty GarrettBeatty force-pushed the gcbeatty/durable-annotations branch from ab1af0b to a921009 Compare June 12, 2026 17:13
@GarrettBeatty GarrettBeatty force-pushed the gcbeatty/durable-annotations branch from a921009 to 925f3b5 Compare June 22, 2026 20:37
@GarrettBeatty GarrettBeatty changed the base branch from dev to gcbeatty/durabletestupdates June 22, 2026 20:37
@GarrettBeatty GarrettBeatty force-pushed the gcbeatty/durable-annotations branch from 45da58d to 35c966c Compare June 23, 2026 16:39
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<!-- src\Function is a separate, self-contained project. Exclude its subtree so this project's
default globs don't pick up its sources or generated obj\AssemblyInfo (which causes CS0579). -->
<DefaultItemExcludes>$(DefaultItemExcludes);src\**</DefaultItemExcludes>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was running into build issue so fixed this too

@GarrettBeatty GarrettBeatty marked this pull request as ready for review June 23, 2026 20:38
@GarrettBeatty GarrettBeatty requested review from a team as code owners June 23, 2026 20:38
@GarrettBeatty GarrettBeatty requested review from normj and philasmar and removed request for a team June 23, 2026 20:38
// the exact entry point the hand-written and executable test functions call, so the
// checkpoint/replay/history behavior is identical.
[LambdaFunction]
[DurableExecution]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i manually deployed this too and also played around with updating the attributes and checking that they reflected in the template too

Base automatically changed from gcbeatty/durabletestupdates to dev June 23, 2026 20:48
Add a [DurableExecution] attribute (in Amazon.Lambda.Annotations) and source
generator support so a method annotated with [LambdaFunction] + [DurableExecution]
generates:
- a typed-envelope handler wrapper delegating to DurableFunction.WrapAsync<TInput[,TOutput]>
- a DurableConfig block on the function resource in the generated CFN/SAM template
- lambda:CheckpointDurableExecution / lambda:GetDurableExecutionState IAM permissions
  (per-function inline policy; skipped when an explicit Role is set)

Validation gates (AWSLambda0140-0143) require durable functions to be executable
(OutputKind), Zip-packaged, and have the (TInput, IDurableContext) -> Task/Task<TOutput>
signature; combining with another event attribute reuses the existing AWSLambda0102.

The generated WrapAsync call emits explicit generic type arguments because method-group
arguments cannot be inferred for the Func<,,> parameter (CS0411).

fiox build

annotations

updates

updates

update docs

pr comments
@GarrettBeatty GarrettBeatty force-pushed the gcbeatty/durable-annotations branch from 183524b to 5a5447e Compare June 23, 2026 20:49
// Assembly::Type::Method), which LambdaFunctionModel.Handler already derives from IsExecutable. So no
// OutputKind gate is needed here.

// Image packaging strips Handler/Runtime from the function resource, which the durable

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this comment and why image functions don't work. Especially since that is how we tell customers to test the preview. Maybe a quick sync up between us to help me understand what is causing the issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be AI slop. I also asked Claude about this, I think he mentioned the other annotations have the same limitation. I'll double check

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 3bee3f5. claude incorrectly assumed some things

@GarrettBeatty GarrettBeatty requested a review from normj June 24, 2026 12:44

@philasmar philasmar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Resource: "*" on the IAM policy — The inline checkpoint policy grants lambda:CheckpointDurableExecution and lambda:GetDurableExecutionState on "*". The comment says this is a known preview limitation pending a scopable ARN format. This is fine for preview, but should be tracked as a follow-up to scope down once the service supports it. Consider adding a TODO comment or linking an issue so this doesn't get forgotten post-GA.
  2. Diagnostic ID gap — The AnalyzerReleases.Unshipped.md lists AWSLambda0142-0144, but the design doc mentions AWSLambda0141 was intended for a Zip-packaging validation. Either allocate 0141 for the Zip check (the validation is mentioned in the PR description) or document why it was skipped to avoid confusion if someone later tries to use that ID.
  3. IsDurableCheckpointStatement uses string serialization — The helper IsDurableCheckpointStatement serializes the policy object to JSON and checks for a substring match on the Sid. This works but is fragile if the Sid string ever appears in a comment or different context. A more robust approach would be to try casting the object to Dictionary<string, object> and checking the structure directly. Low risk in practice but worth noting.
  4. Design doc checked in — docs/design/annotations-integration-plan.md is a superseded planning artifact with outdated information (e.g., references to
    AWSLambda0140 that was never allocated, "executable-only" gating that was removed). Consider removing it or moving it to a wiki/issue to avoid confusion for future contributors reading the source tree.

@GarrettBeatty

Copy link
Copy Markdown
Contributor Author

Diagnostic ID gap — The AnalyzerReleases.Unshipped.md lists AWSLambda0142-0144, but the design doc mentions AWSLambda0141 was intended for a Zip-packaging validation. Either allocate 0141 for the Zip check (the validation is mentioned in the PR description) or document why it was skipped to avoid confusion if someone later tries to use that ID.
IsDurableCheckpointStatement uses string serialization — The helper IsDurableCheckpointStatement serializes the policy object to JSON and checks for a substring match on the Sid. This works but is fragile if the Sid string ever appears in a comment or different context. A more robust approach would be to try casting the object to Dictionary<string, object> and checking the structure directly. Low risk in practice but worth noting.

i dont think these are actual issues

@GarrettBeatty

Copy link
Copy Markdown
Contributor Author

Resource: "" on the IAM policy — The inline checkpoint policy grants lambda:CheckpointDurableExecution and lambda:GetDurableExecutionState on "". The comment says this is a known preview limitation pending a scopable ARN format. This is fine for preview, but should be tracked as a follow-up to scope down once the service supports it. Consider adding a TODO comment or linking an issue so this doesn't get forgotten post-GA.

fixed in latest commit

@GarrettBeatty GarrettBeatty requested a review from philasmar June 24, 2026 22:05
@GarrettBeatty GarrettBeatty merged commit b9a5176 into dev Jun 25, 2026
5 checks passed
@GarrettBeatty GarrettBeatty deleted the gcbeatty/durable-annotations branch June 25, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants